<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title></title>
	<link rel="stylesheet" type="text/css" href="${base}/statics/easyui/material/easyui.css">
	<link rel="stylesheet" type="text/css" href="${base}/statics/easyui/icon.css">
	<script type="text/javascript" src="${base}/statics/easyui/jquery.min.js"></script>
	<script type="text/javascript" src="${base}/statics/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${base}/statics/easyui/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="${base}/statics/easyui/common.js"></script>
	<script type="text/javascript" src="${base}/statics/lib/layer/2.1/layer.js"></script> 
	<script type="text/javascript" src="${base}/statics/h-ui/js/H-ui.js"></script> 
	<script type="text/javascript" src="${base}/statics/h-ui.admin/js/H-ui.admin.js"></script> 
</head>
<body class="easyui-layout">
<div data-options="region:'center'" style="padding:8px 0 0 20px">
	<table style="width:100%;height:0px" id="tb_datagrid"></table>
</div>

<script type="text/javascript">
	
	$(function(){
		
		datagrid();
		
	});
	var toolbar = [{
		text:'添加',
		iconCls:'icon-add',
		handler:function(){
			//layer_show("添加菜单","${ctrname}/add","","500",function(){});
			var dialog=layer.open({
		      type: 2,
		      title: '添加商品',
		      shadeClose: true,
		      shade: false,
		      maxmin: true, //开启最大化最小化按钮
		      area: ['893px', '600px'],
		      content: '${ctrname}/add'
		    });
			layer.full(dialog);
		}
	},{
		text:'修改',
		iconCls:'icon-edit',
		handler:function(){
			var nodes=$('#tb_datagrid').treegrid("getSelections");
			if(nodes!=null&&nodes.length>1){
				layer.msg("只能选中一条记录");
				return;
			}
			var data=$('#tb_datagrid').treegrid("getSelected");
			if(data==null){
				layer.msg("请选中一条记录");
				return;
			}
			layer_show("添加菜单","${ctrname}/edit?id="+data.brand_id,"","500",function(){});
		}
	},'-',{
		text:'删除',
		iconCls:'icon-remove',
		handler:function(){
			var nodes=$('#tb_datagrid').treegrid("getSelections");
			if(nodes!=null&&nodes.length>1){
				layer.msg("只能选中一条记录");
				return;
			}
			var data=$('#tb_datagrid').treegrid("getSelected");
			if(data==null){
				layer.msg("请选中一条记录");
				return;
			}
			layer.confirm('是否删除【'+data.brand_name+'】?', {
			  btn: ['确定','取消'] //按钮
			}, function(){
				$.getJSON("${ctrname}/remove?id="+data.brand_id,function(data){
					layer.msg(data.msg);
					if(data.status==1){
						datagrid();
					}
				});
			}, function(){
			  
			});
			
		}
	}];
	
	function datagrid(){
		$('#tb_datagrid').datagrid({
			url:'${ctrname}/datagrid',
			rownumbers:true,
			singleSelect:false,
			pageSize:20,           
			pagination:true,
			multiSort:true,
			
			fit:true,
			toolbar:toolbar,
			columns:[[
				{ field:'product_logo',title:'商品LOGO',width:60,formatter: function(value, row, index){
					return '<img style="width:25px;height:25px;" src="'+value+'">';
				}},
				{ field:'product_name',title:'商品名称',width:100},
				{ field:'category_id',title:'所属分类',width:100},
				{ field:'brand_id',title:'所属品牌',width:100},
				{ field:'rule_id',title:'规格',width:100},
				{ field:'product_mark',title:'商品货号',width:80},
				{ field:'product_money',title:'活动价',width:80},
				{ field:'product_smoney',title:'商品商城价',width:100},
				{ field:'product_mmoney',title:'商品市场价',width:100},
				{ field:'product_wlmoney',title:'商品物流价',width:100},
				{ field:'product_point',title:'赠送积分',width:100},
				{ field:'product_text',title:'商品描述',width:100},
				{ field:'product_desc',title:'页面描述',width:100},
				{ field:'product_keys',title:'页面关键词',width:100},
				{ field:'product_weight',title:'商品尺寸',width:100},
				{ field:'product_state',title:'商品状态',width:100},
				{ field:'product_num',title:'商品库存数',width:100},
				{ field:'product_sellnum',title:'商品销售数',width:100},
				{ field:'product_clicknum',title:'商品点击数',width:100},
				{ field:'product_collectnum',title:'商品收藏数',width:100},
				{ field:'product_asknum',title:'商品咨询数',width:100},
				{ field:'product_commentnum',title:'商品评价数',width:100},
				{ field:'product_commentrate',title:'商品评价比例',width:100},
				{ field:'product_commentstar',title:'商品评价星级',width:100},
				{ field:'product_hd_tag',title:'活动标签',width:100},
				{ field:'product_hd_stime',title:'活动开始时间',width:100},
				{ field:'product_hd_etime',title:'活动结束时间',width:100},
				{ field:'product_istuijian',title:'是否推荐',width:60},
				
			]],
			onLoadSuccess:function(){
				$("#tb_datagrid").css("height",$(window).height()-20);
			}
		});
	}
	
</script>
</body>
</html>